package com.comac.print.component.app.enums;


import com.comac.print.component.app.command.CommandExe;
import com.comac.print.component.app.command.cmdExe.FoFollowCmdExe;
import lombok.Getter;
import lombok.Setter;

import java.util.Arrays;

/**
 * @Description 业务场景
 * @Author yy
 * @Date 2021/9/8 14:10
 */
public enum ScenarioEnum {
    /**
     * fo工单打印
     */
    FO_FOLLOW_PRINT("1", FoFollowCmdExe.class);


    @Getter
    @Setter
    private String code;
    @Getter
    @Setter
    private Class<? extends CommandExe> clazz;

    ScenarioEnum(String code, Class<? extends CommandExe> clazz) {
        this.code = code;
        this.clazz = clazz;
    }

    /**
     * 根据编码查询操作
     *
     * @param code
     * @return
     */
    public static ScenarioEnum getScenarioEnumByCode(String code) {
        return Arrays.stream(ScenarioEnum.values())
                .filter(scenarioEnum -> scenarioEnum.getCode().equals(code))
                .findFirst()
                .orElse(null);
    }
}
